package com.sharing.controller;

import com.sharing.common.Result;
import com.sharing.domain.UserLogin;
import com.sharing.service.UserLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author MingTian
 * @version 1.0
 * @description TODO
 * @date 2023/6/22 23:57
 */
@RestController
@RequestMapping("/userLogin")
public class UserLoginController {
    @Autowired
    private UserLoginService userLoginService;

    /**
     * 查询在指定时间范围内用户的登陆数
     * @param duration 指定时间范围
     * @return
     */
    @GetMapping("/userLoginNumber")
    public Result<List<Long>> selectUserLoginNumber(Integer duration) {
        return userLoginService.selectUserLoginNumber(duration);
    }

    /**
     * 新增用户登录信息
     * @param userLogin
     * @return
     */
    @PostMapping
    public Result<Integer> insertUserLogin(@RequestBody UserLogin userLogin) {
        return userLoginService.insertUserLogin(userLogin);
    }

    /**
     * 删除用户登录信息
     * @param id
     * @return
     */
    @DeleteMapping
    public Result<Integer> deleteUserLogin(Integer id) {
        return userLoginService.deleteUserLogin(id);
    }
}
